﻿using System.Globalization;
using System.Windows.Controls;

namespace MvvmEx.ValidationRules
{
    /// <summary>
    /// 非空验证
    /// </summary>
    public class RequiredRule : ValidationRule
    {
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            if (value == null || string.IsNullOrWhiteSpace(value.ToString()))
            {
                return new ValidationResult(false, "不能为空！");
            }

            return new ValidationResult(true, null);
        }
    }
}